import { createApp } from 'vue'
import pinia from './stores'
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import 'element-plus/dist/index.css'
import App from './App.vue'
import router from './router'
import './styles/index.scss'
import ElSvg from './components/SvgIcon/ElSvg'
import './permission'

import Category from '@/components/category/index.vue'
const app = createApp(App)
// 注册全局组件
app.component('Category',Category)

import { useUserInfoStore } from './stores/userInfo'
// 自定义指令
app.directive('visite',{
  mounted(a,b){
    console.log(b);
    //如果仓库里面buttons数组没有这个标记干掉即可
    if(!useUserInfoStore().buttonsList.includes(b.value)){
      // 删除DOM
      a.parentNode.removeChild(a);
    }
  }
})

// 引入mock文件
import './mock/mockServe'

//vue-echarts设置
import ECharts from 'vue-echarts'
import { use } from "echarts/core"

// import ECharts modules manually to reduce bundle size
import {
  CanvasRenderer
} from 'echarts/renderers'
import {
  BarChart
} from 'echarts/charts'
import {
  GridComponent,
  TooltipComponent
} from 'echarts/components'

use([
  CanvasRenderer,
  BarChart,
  GridComponent,
  TooltipComponent
]);

//全局组件v-chart
app.component('v-chart',ECharts)


ElSvg(app)
app.use(pinia)
  .use(router)
  .use(ElementPlus, {
    locale: zhCn,
  })
  .mount('#app')
